﻿create PROCEDURE Sync.SP_CustomerLoanHistory_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[LoanHistoryID],
		g.[LoanID],g.[CustomerName],g.[LoanExecutionDate],g.[LoanProjectStageID],g.[OldCustomerCode],g.[LastConsecutiveDelay],g.[LastDiscreteDelay],g.[LoanCloseDate],g.[Notes],g.[LoanHistoryCloseTypeID],
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[CustomerLoanHistory] g RIGHT JOIN Sync.CustomerLoanHistory_Tracking t  
    ON t.LoanHistoryID = g.LoanHistoryID 
	WHERE @LastRowVersion IS NULL OR t.Version > @LastRowVersion
    END














